package chapter9.section7;

public class PackagingType {
    public static void main(String[] args) {
        String numStr = "123";
        // String转Integer
        Integer num1 = Integer.parseInt(numStr); // 返回 int 类型，然后转为 Integer
        Integer num2 = Integer.valueOf(numStr); // 返回 Integer 类型
        System.out.println(num1);
        System.out.println(num2);
        
        System.out.println("\n--- 自动装箱/拆箱演示 ---");
        // 自动装箱
        Integer autoBoxed = 100;
        // 自动拆箱
        int autoUnboxed = autoBoxed;
        System.out.println("自动装箱: " + autoBoxed);
        System.out.println("自动拆箱: " + autoUnboxed);
        
        // 数值比较演示
        System.out.println("\n--- 数值比较演示 ---");
        Integer a = 12;
        Integer b = 12;
        Integer c = 34;
        System.out.println("a == b : " + (a.equals(b)));
        System.out.println("a == c : " + (a.equals(c)));

        // 不同类型包装类演示
        System.out.println("\n--- 不同类型包装类演示 ---");
        Double doubleVal = 3.14;
        Boolean boolVal = true;
        Character charVal = 'A';
        System.out.println("Double: " + doubleVal);
        System.out.println("Boolean: " + boolVal);
        System.out.println("Character: " + charVal);
        
        // 类型转换演示
        System.out.println("\n--- 类型转换演示 ---");
        System.out.println("Integer转String: " + num1.toString());
        System.out.println("Double转int: " + doubleVal.intValue());
        System.out.println("Character转int: " + (int)charVal);
    }
}